package com.cssy.xxkj.basic.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.xxkj.basic.dao.BasicContactRecordDAO;
import com.cssy.xxkj.basic.entity.BasicCompanyTestDO;
import com.cssy.xxkj.basic.entity.BasicContactRecordDO;
import com.cssy.xxkj.basic.service.IBasicContactRecordService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;
@Service("basicContactRecordService")
public class BasicContactRecordServiceImpl implements IBasicContactRecordService {
	@Resource(name="basicContactRecordDAO")
	private BasicContactRecordDAO basicContactRecordDAO;
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicContactRecordDO>  list=basicContactRecordDAO.find(scs);
		rs.setRecordCount(basicContactRecordDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		
		return null;
	}

	@Override
	public Integer update(BasicContactRecordDO t, User user)
			throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BasicContactRecordDO save(BasicContactRecordDO t, User user)
			throws SyBaseException {
		String id=IDCodeTypeUtil.getId();
		t.setId(id);
		t.setBizCreatorName(user.getName());
		t.setBizCreatorDate(new Date());
		t.setBizVersion(1);
		t.setBizModifyName(user.getName());
		basicContactRecordDAO.insertBasicContactRecordDO(t);
		return t;
	}

	@Override
	public BasicContactRecordDO findListById(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deleteAllByCustId(String custId) {
		basicContactRecordDAO.deleteAllByCustId(custId);
		
	}

	@Override
	public BasicContactRecordDO saveBasicContactRecordDOByBasicCompanyTestDO(
			BasicCompanyTestDO cdo, BasicContactRecordDO bcrd, User user) {
		bcrd.setZd001CustId(cdo.getId());
		bcrd.setZd001CustCode(cdo.getZd001Code());
		bcrd.setZd001CustEnName(cdo.getZd002EnName());
		bcrd.setZd001CustZhName(cdo.getZd003ZhName());
		bcrd.setZd005WeId("");
		bcrd.setZd005WeCode("");
		bcrd.setZd005WeName("");
		return  this.save(bcrd, user);
	}

}
